﻿Public Class MainForm

    Private _lastControl As Control
    Public ReadOnly Property LastControl() As Control
        Get
            If _lastControl Is Nothing Then
                Return Me
            End If

            Return _lastControl
        End Get
      
    End Property
    Private Sub 添加水平分割ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 添加水平分割ToolStripMenuItem.Click

        Dim SplitContainer1 As New System.Windows.Forms.SplitContainer
        SplitContainer1.Orientation = Orientation.Horizontal

        'SplitContainer1
        '
        SplitContainer1.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(0, Byte), Integer))
        SplitContainer1.Dock = System.Windows.Forms.DockStyle.Fill
        SplitContainer1.Location = New System.Drawing.Point(0, 0)
        SplitContainer1.Name = "SplitContainer1"
        '
        'SplitContainer1.Panel1
        '
        SplitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Control
        AddHandler SplitContainer1.Panel1.Click, AddressOf MainForm_Click
        AddHandler SplitContainer1.Panel1.MouseClick, AddressOf MainForm_MouseClick
        AddHandler SplitContainer1.Panel1.MouseDoubleClick, AddressOf MainForm_MouseDoubleClick
        AddHandler SplitContainer1.Panel1.MouseMove, AddressOf MainForm_MouseMove
        '
        'SplitContainer1.Panel2
        '
        AddHandler SplitContainer1.Panel2.Click, AddressOf MainForm_Click
        AddHandler SplitContainer1.Panel2.MouseClick, AddressOf MainForm_MouseClick
        AddHandler SplitContainer1.Panel2.MouseDoubleClick, AddressOf MainForm_MouseDoubleClick
        AddHandler SplitContainer1.Panel2.MouseMove, AddressOf MainForm_MouseMove
        SplitContainer1.Panel2.BackColor = System.Drawing.SystemColors.Control
        SplitContainer1.Size = New System.Drawing.Size(712, 521)
        SplitContainer1.SplitterDistance = 237
        SplitContainer1.ContextMenuStrip = Me.ContextMenuStrip1
        LastControl.Controls.Add(SplitContainer1)
    End Sub

    Private Sub 添加垂直分割ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 添加垂直分割ToolStripMenuItem.Click
        Dim SplitContainer1 As New System.Windows.Forms.SplitContainer

        'SplitContainer1
        '
        SplitContainer1.BackColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(0, Byte), Integer))
        SplitContainer1.Dock = System.Windows.Forms.DockStyle.Fill
        SplitContainer1.Location = New System.Drawing.Point(0, 0)
        SplitContainer1.Name = "SplitContainer1"
        '
        'SplitContainer1.Panel1
        '
        AddHandler SplitContainer1.Panel1.Click, AddressOf MainForm_Click
        AddHandler SplitContainer1.Panel1.MouseClick, AddressOf MainForm_MouseClick
        AddHandler SplitContainer1.Panel1.MouseDoubleClick, AddressOf MainForm_MouseDoubleClick
        AddHandler SplitContainer1.Panel1.MouseMove, AddressOf MainForm_MouseMove
        SplitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Control
        '
        'SplitContainer1.Panel2
        '
        AddHandler SplitContainer1.Panel2.Click, AddressOf MainForm_Click
        AddHandler SplitContainer1.Panel2.MouseClick, AddressOf MainForm_MouseClick
        AddHandler SplitContainer1.Panel2.MouseDoubleClick, AddressOf MainForm_MouseDoubleClick
        AddHandler SplitContainer1.Panel2.MouseMove, AddressOf MainForm_MouseMove
        SplitContainer1.Panel2.BackColor = System.Drawing.SystemColors.Control
        SplitContainer1.Size = New System.Drawing.Size(712, 521)
        SplitContainer1.SplitterDistance = 237
        SplitContainer1.ContextMenuStrip = Me.ContextMenuStrip1
        LastControl.Controls.Add(SplitContainer1)
       
    End Sub

    Private Sub 删除当前分割ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 删除当前分割ToolStripMenuItem.Click

    End Sub


    Private Sub MainForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        _lastControl = sender
    End Sub

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler Me.Click, AddressOf MainForm_Click
        AddHandler Me.MouseClick, AddressOf MainForm_MouseClick
        AddHandler Me.MouseDoubleClick, AddressOf MainForm_MouseDoubleClick
        AddHandler Me.MouseMove, AddressOf MainForm_MouseMove
    End Sub

    Private Sub MainForm_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        _lastControl = sender
    End Sub

    Private Sub MainForm_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        _lastControl = sender
    End Sub

    Private Sub MainForm_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        _lastControl = sender
    End Sub
End Class
